/*
 *  PickCallback.h
 *  Squirrels
 *
 *  Created by Dmitry Fadeev on 9/22/11.
 *  Copyright 2011 Arello Mobile. All rights reserved.
 *
 */

#pragma once

#include <Box2D/Dynamics/b2Fixture.h>
#include <physics/Node.h>
#include <Box2D/Dynamics/b2WorldCallbacks.h>

namespace physics
{

class PickCallback : public b2QueryCallback
{
private:
	b2Fixture * _fixture;
public:
	inline PickCallback() : _fixture(NULL)
	{
	}
	inline virtual ~PickCallback()
	{
	}
	inline virtual bool ReportFixture(b2Fixture * fixture)
	{
		_fixture = fixture;
		return true;
	}
	inline physics::Node * getNode()
	{
		if(_fixture == NULL)
			return NULL;
		
		return reinterpret_cast<physics::Node*>(_fixture->GetBody()->GetUserData());
	}
};

}